<!--
 * @Author: JPeng 872639397@qq.com
 * @Date: 2022-05-15 11:22:29
 * @LastEditors: JPeng 872639397@qq.com
 * @LastEditTime: 2022-06-10 17:35:51
 * @FilePath: \review-review-review\复习！！！\Promise\手写all.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>手写all</title>
</head>

<body>
    <script>
        Promise.prototype.all = function (arr) {
            return new Promise((resolve, rejected) => {
                let res = [], count = 0;
                for (let i = 0; i < arr.length; i++) {
                    Promise.resolve(arr[i]).then((data) => {
                        res[i] = data;
                        conunt++;
                        if (count === arr.length) resolve(res);
                    }, (err) => {
                        rejected(err);
                    })
                }
            })

        }
    </script>
</body>

</html>